package com.dcy.db.mybatis.model;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @Author：dcy
 * @Description: 数据权限过滤字段对象
 * @Date: 2021/9/8 15:18
 */
@Getter
@Setter
@ToString
public class DataColumnProperty {

    /**
     * 别名
     *
     * @return
     */
    private String alias;

    /**
     * 字段名
     *
     * @return
     */
    private String name;

    /**
     * 拼接字段名称
     */
    private String aliasName;

    public DataColumnProperty() {

    }

    public DataColumnProperty(String alias, String name, String aliasName) {
        this.alias = alias;
        this.name = name;
        this.aliasName = aliasName;
    }

    public String getAliasName() {
        String column = this.name;
        if (StrUtil.isNotBlank(this.alias)) {
            column = StrUtil.builder().append(this.alias).append(StringPool.DOT).append(this.name).toString();
        }
        return column;
    }

}
